Copy attribute value from one object to another - multi-value enum?

 

Is there no easy way to copy an attribute value from one object to another when the attribute is a multi-valued enumeration?

I did find a klugey solution that copied the source value to a string, and then extracted each line of the string and then assigned each of those to the target.

But I thought there would be a more elegant way...like:

Object o_source, o_target

string multiEnumAttr="Allocation"

o_target.multiEnumAttr = o_source.multiEnumAttr

But that doesn't work.

-Colin


strathglass - Thu Oct 31 11:36:12 EDT 2013

Re: Copy attribute value from one object to another - multi-value enum?
llandale - Thu Oct 31 13:21:35 EDT 2013

If your "Allocation" attribute is defined the same way in both modules your assignment should work.  Except, well, you need to turn the attr reference into a string by double-double quotes:

  • oT.Name = oS.Name ""

There is a better undocumented perm which copies everything.

  • string ErrorMessage = set(oT.Name, oS.Name)

But, as always, the data being copied needs to be compatible with the "type" of the target attribute.  Noteworthy would be you cannot copy a multi-value that has more than one selected into a single value (since the copied value has an EOL in it); and of course the copied values have to exist in the target attr type.

-Louie

Re: Copy attribute value from one object to another - multi-value enum?
strathglass - Thu Oct 31 13:25:38 EDT 2013

llandale - Thu Oct 31 13:21:35 EDT 2013

If your "Allocation" attribute is defined the same way in both modules your assignment should work.  Except, well, you need to turn the attr reference into a string by double-double quotes:

  • oT.Name = oS.Name ""

There is a better undocumented perm which copies everything.

  • string ErrorMessage = set(oT.Name, oS.Name)

But, as always, the data being copied needs to be compatible with the "type" of the target attribute.  Noteworthy would be you cannot copy a multi-value that has more than one selected into a single value (since the copied value has an EOL in it); and of course the copied values have to exist in the target attr type.

-Louie

Thanks Louie, I'll try that ... I was sure I had tried the double quote cast thing, but maybe not (or maybe I only tried it on the left hand).

(I was figuring it was a syntax issue!)

The two objects are in the same module and its the same attribute (just copying from one obj to another), so there really should be no issue.

I didn't know about the perm, so that is good to know.

Thanks again

-Colin

Re: Copy attribute value from one object to another - multi-value enum?
llandale - Thu Oct 31 13:47:39 EDT 2013

llandale - Thu Oct 31 13:21:35 EDT 2013

If your "Allocation" attribute is defined the same way in both modules your assignment should work.  Except, well, you need to turn the attr reference into a string by double-double quotes:

  • oT.Name = oS.Name ""

There is a better undocumented perm which copies everything.

  • string ErrorMessage = set(oT.Name, oS.Name)

But, as always, the data being copied needs to be compatible with the "type" of the target attribute.  Noteworthy would be you cannot copy a multi-value that has more than one selected into a single value (since the copied value has an EOL in it); and of course the copied values have to exist in the target attr type.

-Louie

Oops, looking at my notes.  "set" returns nothing, you need to wrap it:

  • noError()
  • set(oT.Name, oS.Name)
  • ErrMess = lastError()